﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Traceable.App.Application.Command.Aquaculture;
using Traceable.App.DTOS;
using Traceable.ErrorCode;

namespace Traceable.App.Controllers
{
    /// <summary>
    /// 公共服务
    /// </summary>
    [Route("api/[controller][action]")]
    [ApiController]
    public class CommonController : ControllerBase
    {
        IMediator _mediator;
        /// <summary>
        /// 依赖注入master
        /// </summary>
        /// <param name="mediator"></param>
        /// <summary>
        /// 依赖注入开发分支
        /// </summary>
        /// <param name="mediator"></param>
        public CommonController(IMediator mediator)
        {
            _mediator = mediator;
        }

        /// <summary>
        /// 获取公司企业信息
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        [HttpGet]
        public Task<ApiResult<EnterpriseDto>> GetCompany([FromQuery]SelectCompanyCommand request)
        {
            return _mediator.Send(request);
        }
        /// <summary>
        /// 养殖公司企业添加
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        [HttpPost]
        public Task<ApiResult<int>> CreateCompany(CreateEnterpriceCommand request)
        {
            return _mediator.Send(request);
        }
        /// <summary>
        /// 保存图片到数据库
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        [HttpPost]
        public Task<ApiResult<int>> UpImages(UpImageListCommand request)
        {
            return _mediator.Send(request);
        }
        /// <summary>
        /// 获取图片信息
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        [HttpGet]
        public Task<ApiResult<List<ImageDto>>> GetImagelist([FromQuery]GetImageListCommand request)
        {
            return _mediator.Send(request);
        }
        /// <summary>
        /// 照片删除
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        [HttpDelete]
        public Task<ApiResult<int>> Deleteimage([FromQuery]DeleteImageCommand request)
        {
            return _mediator.Send(request);
        }
    }

}
